package com.hx.company.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hx.company.ManagerInterface;
import com.hx.company.dao.ManagerDao;
import com.hx.company.dao.UserDao;
import com.hx.company.vo.Admin;
import com.hx.company.vo.Merchant;
import com.hx.company.vo.UserLogin;
@Service("mi")
public class ManagerInterfaceImpl implements ManagerInterface{
	@Autowired(required=true)
	private ManagerDao md;
	@Override
	@Transactional
	public Boolean ManagerLogin(Admin a) {
		System.out.println("........"+a.getAname()+a.getApassword());
		List<Admin> cs=new ArrayList<Admin>();
		 cs=md.find(a);
		Boolean i=false;
		for(Admin ad:cs){
			if(ad.getApassword().equals(a.getApassword())){
				i=true;
			}
			
		}
		return i;
	}
	

	@Override
	@Transactional
	public Admin addManager(Admin a) {
		System.out.println(a.toString());
		return md.addAdmin(a) ;
		// TODO Auto-generated method stub
		//return md.addAdmin();
	}

	@Override
	public List<Merchant> getMerchant() {
		// TODO Auto-generated method stub
	 
		return md.findAll();
				
			}
	     

	@Override
	public Boolean setMerchant(int id) {
		// TODO Auto-generated method stub
		return md.accMercha(id);
	}

	@Override
	public List<?> getEvaluate() {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public Boolean addManager(String name, String password, int author) {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public void deleteMerch(int id) {
		// TODO Auto-generated method stub
		 md.deleteMerch( id);
	}

}
